package com.dcrain.api.authz.exception;

import com.dcrain.api.authz.common.ApiCodeEnum;

/**
 * 自定义异常
 * 
 */
public class ApiRException extends RuntimeException {
	private static final long serialVersionUID = 1L;
	private String msg;
	private String code = ApiCodeEnum.UNKNOW_ERROR.getCode();
	public ApiRException() {
		super(ApiCodeEnum.UNKNOW_ERROR.getMsg());
		this.msg = ApiCodeEnum.UNKNOW_ERROR.getMsg();
	}

	public ApiRException(ApiCodeEnum rcode) {
		super(rcode.getMsg());
		this.msg = rcode.getMsg();
		this.code = rcode.getCode();
	}

	public ApiRException(ApiCodeEnum rcode, Throwable e) {
		super(rcode.getMsg(),e);
		this.msg = rcode.getMsg();
		this.code = rcode.getCode();
	}
	
	public ApiRException(ApiCodeEnum rcode,String msg) {
		super(rcode.getMsg()+":"+msg);
		this.msg = rcode.getMsg()+":"+msg;
		this.code = rcode.getCode();
	}
	
	public ApiRException(String msg) {
		super(msg);
		this.msg = msg;
	}
	
	public ApiRException(String msg, Throwable e) {
		super(msg, e);
		this.msg = msg;
	}
	
	public ApiRException(String code, String msg) {
		super(msg);
		this.msg = msg;
		this.code = code;
	}

	public ApiRException(String code,String msg,Throwable e) {
		super(msg, e);
		this.msg = msg;
		this.code = code;
	}
    /////////////////////
	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
}
